<?php

namespace App\Containers\AppSection\Confirmation\Tasks;

use App\Containers\AppSection\Confirmation\Data\Repositories\ConfirmationRepository;
use App\Ship\Criterias\Where;
use App\Ship\Parents\Tasks\Task;

class GetConfirmationsTask extends Task
{
    protected ConfirmationRepository $repository;

    public function __construct(ConfirmationRepository $repository)
    {
        $this->repository = $repository;
    }

    public function run()
    {
        return $this->repository->paginate();
    }

    public function forType($type): self
    {
        $this->repository->pushCriteria(new Where('confirm_type', '=', $type));

        return $this;
    }
}
